package com.lframework.xingyun.promo.mappers;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.lframework.starter.web.core.mapper.BaseMapper;
import com.lframework.xingyun.promo.entity.MarketingNthpiece;
import com.lframework.xingyun.promo.vo.nthpiece.QueryMarketingNthpieceVo;

import java.util.List;
import java.util.Objects;

/**
 * <p>
 * 限时第N件活动表 Mapper 接口
 * </p>
 *
 */
public interface MarketingNthpieceMapper extends BaseMapper<MarketingNthpiece> {

    /**
     * 查询列表
     * @param vo
     * @return
     */
    default IPage<MarketingNthpiece> queryPage(QueryMarketingNthpieceVo vo) {
        return defaultJoinWrapper()
                .like(StrUtil.isNotBlank(vo.getName()), MarketingNthpiece::getName, vo.getName())
                .eq(Objects.nonNull(vo.getDiscountType()), MarketingNthpiece::getDiscountType, vo.getDiscountType())
                .page(PageDTO.of(vo.getPageIndex(), vo.getPageSize()));
    }

    /**
     * 查询列表
     * @param vo
     * @return
     */
    default List<MarketingNthpiece> queryList(QueryMarketingNthpieceVo vo) {
        return defaultJoinWrapper()
                .like(StrUtil.isNotBlank(vo.getName()), MarketingNthpiece::getName, vo.getName())
                .eq(Objects.nonNull(vo.getDiscountType()), MarketingNthpiece::getDiscountType, vo.getDiscountType())
                .list();
    }
}

